<template>
  <div class="form-item">
    <div class="item-label">{{ label }}</div>
    <div class="item-content">
      <van-switch v-model="checked" />
    </div>
  </div>
</template>
<script>
export default {
  props: {
    label: {
      type: String,
      default: ''
    },
    value: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      text: this.value,
      checked: true
    }
  },
  watch: {
    value(newVal) {
      this.text = newVal
    },
    text(newVal) {
      this.$emit('input', newVal)
    }
  }
}
</script>
<style lang="less" scoped>
.form-item {
  display: flex;
  height: 36px;
  padding: 7px 0;
  margin: 0 15px;
  border-bottom: 1px solid #f2f2f2;
  .item-label {
    line-height: 36px;
    font-size: 14px;
    color: #011445;
    opacity: 0.6;
    margin-right: 15px;
  }
  .item-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
}

</style>